from memory_profiler import profile

from decorators.decorators import print_execution_time, calculate_execution_time, calculate_execution_memory


@profile
def find_max(numbers):
    """找到线性表中的最大值"""
    max_value = float('-inf')
    for num in numbers:
        if num > max_value:
            max_value = num
    return max_value


@print_execution_time
def find_min(numbers):
    """找到线性表中的最小值"""
    min_value = float('inf')
    for num in numbers:
        if num < min_value:
            min_value = num
    return min_value


@calculate_execution_time
def calculate_average(numbers):
    """计算线性表的平均值"""
    total = sum(numbers)
    average = total / len(numbers)
    return average


@calculate_execution_memory
def sort_list(numbers):
    """对线性表进行排序"""
    sorted_list = sorted(numbers)
    return sorted_list


# 示例使用
my_numbers = [10, 5, 8, 3, 9]

max_value = find_max(my_numbers)
min_value = find_min(my_numbers)
average_value = calculate_average(my_numbers)
sorted_values = sort_list(my_numbers)

print("最大值:", max_value)
print("最小值:", min_value)
print("平均值:", average_value)
print("排序后的列表:", sorted_values)
